using System.Web;

namespace LeanUi.ImageBundle
{
    public static class ImageBundleDirs
    {
        private static string CombinePath(string a, string b)
        {
            if (a.Length == 0)
                return b;
            return a.EndsWith("/") 
                ? a + b 
                : a + "/" + b;
        }
               
        //"http://img.domain.org/"
        private static string _staticContentDir;
        public static string StaticContentDir
        {
            set { _staticContentDir = value; }
            get { return _staticContentDir ?? HttpRuntime.AppDomainAppVirtualPath ?? ""; }  
        }

        public static string ImageDir
        {
            get { return CombinePath(StaticContentDir, "images"); }
        }

        public static string CssDir
        {
            get { return CombinePath(StaticContentDir, "styles"); }
        }

        public static string ImageFile(string filename)
        {
            return CombinePath(ImageDir, filename);
        }

        public static string CssFile(string filename)
        {
            return CombinePath(CssDir, filename);
        }
    }
}